package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.query.DestinationQuery;
import cn.wolfcode.luowowo.article.query.RegionQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.data.annotation.Id;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.management.Query;

/**
 * Created by LENOVO on 2019/8/10.
 */

@Controller
@RequestMapping("destination")
public class DestinationController {
    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") DestinationQuery qo){
        PageInfo pageInfo = destinationService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        //默认的查询没有父类的根 目的地
        model.addAttribute("toasts",destinationService.getToasts(qo.getParentId()));
        return "destination/list";
    }


    //目的地的热门设置   changeHotValue
    @RequestMapping("/changeHotValue")
    @ResponseBody
    public Object changeHotValue(int hot ,Long id){
        destinationService.changeHotValue(hot,id);
        return AjaxResult.SUCCESS;
    }
    //目的地的删除
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        destinationService.delete(id);
        return AjaxResult.SUCCESS;
    }
}
